<!--菜单搜索功能-->
<!--先写静态页面-->
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Green-download</title>
    <style>
        * {
            box-sizing: border-box;
        }
        
        .container {
            padding: 10px;
        }
        
        .dnav {
            float: left;
            padding: 5px;
            background: grey;
        }
        
        .dnav ul {
            list-style-type: none;
            margin: 10px;
            padding: 0px;
        }
        
        .dnav ul li {
            height: 20px;
        }
        
        .dnav ul li a {
            padding: 10px;
            margin: 20px;
            text-decoration: none;
            font-size: 18px;
            color: black;
            display: block
        }
        
        .dnav ul li a:hover {
            color: white;
        }
        
        .dnav input {
            width: 100%;
            font-size: 18px;
            padding: 11px;
            border: 1px solid #ddd;
        }
        
        .content {
            float: left;
            width: 70%;
            padding: 5px;
            background: lightgrey;
        }
    </style>
</head>

<body>
    <div class="container">
        <!--左右布局的实例-->
        <div class="dnav">
            <nav class="nav">
                <h2>索引
                    <h2>
                        <input placeholder="请输入关键字" id="mysearch" onkeyup="search()">
                        <ul>
                            <li><a href="./Debug/git.html">Git</a></li>
                            <LI>
                                <a href="javascript:history.back(-1)">BACK</a>
                            </LI>
                        </ul>
            </nav>
        </div>
        <div class="content">

            <h1>Debug>_</h1>
            <h2>这里有一些实例可能会帮助到你</h2>
        </div>
        <script>
            //功能：主要是过滤，通过转换为大写toUpperCase,然后用indexOff来查询返回字符串位子，无就返回-1
            function search() {
                var input = document.getElementById("mysearch").value;
                var li = document.getElementsByTagName("li");
                var fliter = input.toUpperCase();
                for (var i = 0; i < li.length; i++) {
                    if (li[i].innerHTML.toUpperCase().indexOf(fliter) > -1) {
                        li[i].style.display = "block";
                    } else {
                        li[i].style.display = "none";
                    }

                }

            }
        </script>
</body>

</html>